package com.dodo.blog.server.impl;

import com.comvai.services.persistence.LowLevel;
import com.comvai.services.persistence.PersistenceManager;
import com.comvai.services.persistence.criteria.Criteria;
import com.dodo.blog.model.Playground;
import com.dodo.blog.request.BasicRequest;
import com.dodo.blog.server.PlaygroundService;

import javax.inject.Inject;
import java.util.List;

/**
 * @author <a href="mailto:pohorelec@comvai.com">Jozef Pohorelec</a>
 */
public class PlaygroundServiceBean
        extends AbstractServiceBean
        implements PlaygroundService
{
    @Inject
    public PlaygroundServiceBean( @LowLevel PersistenceManager datastore )
    {
        super( datastore );
    }

    @Override
    public List<Playground> getPlaygroundList( BasicRequest request )
    {
        Criteria<Playground> criteria = Criteria.create( Playground.class );
        processCriteria( criteria, request );

        return datastore.list( criteria );
    }

    @Override
    public void savePlayground( Playground Playground )
    {
        save( Playground );
    }

    @Override
    public Playground getPlaygroundById( Long id )
    {
        return datastore.find( Playground.class, id );
    }

    @Override
    public void deletePlayground( Long id )
    {
        delete( Playground.class, id );
    }
}